#include "front/text_normalize.h"

using namespace std;
using namespace ppspeech;

const wregex mcWregexDashColon(L"(\\d+:\\d+)(-\\d+:\\d+)");

void TextNormalizer::TnReDashColon(wstring* fpInWsentence, const LanguageEnum fcInLanguage)
{
	wsmatch tWsmatch;

	while(regex_search(*fpInWsentence, tWsmatch, mcWregexDashColon))
	{
		string tInSentence = wstring2utf8string(*fpInWsentence);
		string tStrReplace = "";
		string tStrDashColon = wstring2utf8string(tWsmatch[0]);	//匹配到横杆的字符串
		vector<string> tItemDashColon = StrSplit(tStrDashColon, "-");	//按横杆分开

		for(size_t i=0; i<tItemDashColon.size(); i++) {
			if(i > 0) {
				tStrReplace += "to";
			}
			tStrReplace += ReplaceMethod(StrSplit(tItemDashColon[i], ":"), (fcInLanguage==LANG_EN)?RME_en_colon_dianfen:RME_zh_colon_dianfen);
		}

		WstrReplacePosition(fpInWsentence, tWsmatch.position(0), tWsmatch.length(0), utf8string2wstring(tStrReplace));
	}
}
